﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SMART_VIET_V01
{
    public partial class frm_tuychinhtruc : Form
    {
        private frm_vedothi parent;
        Dictionary<string, string> bien;

        public frm_tuychinhtruc()
        {
            InitializeComponent();
        }

        public frm_tuychinhtruc(frm_vedothi parent, Dictionary<string, string> bien, Color xy, Color xyLabel)
        {
            // TODO: Complete member initialization
            this.parent = parent;
            this.bien = bien;

            double startX  = -10;
            double endX = 10;
            double startY = -10;
            double endY = 10;
            int divX = 10;
            int divY = 10;
            int width = 2;

            Double.TryParse(bien["startX"].ToString(), out startX);
            Double.TryParse(bien["endX"].ToString(), out endX);
            Double.TryParse(bien["startY"].ToString(), out startY);
            Double.TryParse(bien["endY"].ToString(), out endY);

            Int32.TryParse(bien["divX"].ToString(), out divX);
            Int32.TryParse(bien["divY"].ToString(), out divY);
            Int32.TryParse(bien["width"].ToString(), out width);

            InitializeComponent();

            this.startX.Value = (Decimal)startX;
            this.endX.Value = (Decimal)endX;
            this.startY.Value = (Decimal)startY;
            this.endY.Value = (Decimal)endY;
            this.divX.Value = divX;
            this.divY.Value = divY; 
            this.penWidth.Value = width;
            this.clTruc.EditValue = xy;
            this.clNhan.EditValue = xyLabel;

            
        }

        private void bt_huy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void bt_chapnhan_Click(object sender, EventArgs e)
        {
            parent.UpdateTrucDothi((Double)startX.Value, 
                (Double)endX.Value, 
                (Double)startY.Value, 
                (Double)endY.Value, 
                (int)this.divX.Value, 
                (int)this.divY.Value, 
                (int)this.penWidth.Value,
                (Color)clTruc.EditValue,
                (Color)clNhan.EditValue
                );
            this.Close();
        }
    }
}
